package com.zzw.springboot.exception;

import com.zzw.springboot.common.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author zzw2000
 * @Date 2022年05月14日 23:46
 * @Description 统一异常处理器
 */
@ControllerAdvice
public class ExceptionAdvice {

    @ExceptionHandler(BusinessException.class)
    @ResponseBody
    public Result handlerException(BusinessException be) {
        be.printStackTrace();
        return Result.error(be.getErrorResult());
    }
}
